/**
 * Copyright (c) 2018, Alex. All rights reserved.
 */
package com.oschina.bottle.common.exception;

import com.oschina.bottle.common.constants.Constant;

/**
 * 带有错误码的异常
 *
 * code定义为long型的对象, 默认code为-1，表示未知异常
 *
 * @author <a href="mailto:zhongchao@gegejia.com">zhong</a>
 * @version 1.0 2018/1/4
 * @since 1.0
 */
public class ErrorCodeException extends BaseException {

    private static final long serialVersionUID = 8942000770734463879L;

    private long code = Constant.UNKNOWN_ERROR;

    public ErrorCodeException() {
        super();
    }

    public ErrorCodeException(long code) {
        this.code = code;
    }

    public ErrorCodeException(String message) {
        super(message);
    }

    public ErrorCodeException(long code, String message) {
        super(message);
        this.code = code;
    }

    public ErrorCodeException(String messageTemplate, Object... params) {
        super(messageTemplate, params);
    }

    public ErrorCodeException(long code, String messageTemplate, Object... params) {
        super(messageTemplate, params);
        this.code = code;
    }

    public ErrorCodeException(Throwable cause) {
        super(cause);
    }

    public ErrorCodeException(long code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    public ErrorCodeException(Throwable cause, String message) {
        super(cause, message);
    }

    public ErrorCodeException(long code, Throwable cause, String message) {
        super(cause, message);
        this.code = code;
    }

    public ErrorCodeException(Throwable cause, String messageTemplate, Object... params) {
        super(cause, messageTemplate, params);
    }

    public ErrorCodeException(long code, Throwable cause, String messageTemplate, Object... params) {
        super(cause, messageTemplate, params);
        this.code = code;
    }

    public long getCode() {
        return code;
    }
}
